import Vue from 'vue'
import Router from 'vue-router'
Vue.use(Router)
// 需要左方向动画的路由用this.$router.togo('****')
Router.prototype.togo = function (path) {
  this.isleft = true
  this.isright = false
  this.push(path)
}
// 需要右方向动画的路由用this.$router.goRight('****')
Router.prototype.goRight = function (path) {
  this.isright = true
  this.isleft = false
  this.push(path)
}
// 需要返回按钮动画的路由用this.$router.goBack()，返回上一个路由
Router.prototype.goBack = function () {
  this.isright = true
  this.isleft = false
  this.go(-1)
}
// 点击浏览器返回按钮执行，此时不需要路由回退
Router.prototype.togoback = function () {
  this.isright = true
  this.isleft = false
}
// 点击浏览器前进按钮执行
Router.prototype.togoin = function () {
  this.isright = false
  this.isleft = true
}
export default new Router({
  mode: 'history',
  routes: [
    {
      path: '/home',
      name: 'index',
      meta: {
        title: '首页'
      },
      component: (resolve) => require(['@/pages/index'], resolve),
      redirect: '/home',
      children: [
        {
          path: '/home',
          name: 'home',
          meta: {
            title: ''
          },
          component: (resolve) => require(['@/pages/index/home'], resolve)
        },
        {
          path: '/story',
          name: 'story',
          meta: {
            title: ''
          },
          component: (resolve) => require(['@/pages/index/story'], resolve)
        },
        {
          path: '/share',
          name: 'share',
          meta: {
            title: '分享'
          },
          component: (resolve) => require(['@/pages/index/share'], resolve)
        },
        {
          path: '/my',
          name: 'my',
          meta: {
            title: '我的'
          },
          component: (resolve) => require(['@/pages/index/my'], resolve)
        }
      ]
    },
    {
      path: '/',
      meta: {
        title: '授权'
      },
      name: 'Detail',
      component: (resolve) => require(['@/pages/auth'], resolve)
    },
    {
      path: '/auth*',
      meta: {
        title: '授权'
      },
      name: 'Detail',
      component: (resolve) => require(['@/pages/auth'], resolve)
    },
    {
      path: '/lookvideo',
      meta: {
        title: ''
      },
      name: 'lookvideo',
      component: (resolve) => require(['@/pages/detailcopy'], resolve)
    },
    {
      path: '/video',
      meta: {
        title: ''
      },
      name: 'video',
      component: (resolve) => require(['@/pages/detail'], resolve)
    },
    {
      path: '/xieyi',
      meta: {
        title: '隐私政策'
      },
      name: 'xieyi',
      component: (resolve) => require(['@/pages/xieyi'], resolve)
    }
  ]
})
